def html_to_c_array(html_file, output_file, array_name):
    with open(html_file, 'rb') as file:
        html_content = file.read()

    array_lines = []
    array_lines.append(f'const char {array_name}[] = {{')

    # Convert each byte to hexadecimal format
    hex_bytes = [f'0x{byte:02X}' for byte in html_content]

    # Split hex bytes into multiple lines to fit 16 bytes per line
    for i in range(0, len(hex_bytes), 16):
        line = ', '.join(hex_bytes[i:i+16])
        array_lines.append(f'    {line},')

    array_lines.append('};')

    with open(output_file, 'w') as file:
        file.write('\n'.join(array_lines))

#修改为你自己的目录
html_file = 'C:/Users/VULCAN/Desktop/led/templates/Iris.html'
output_file = 'C:/Users/VULCAN/Desktop/led/templates/iris.c'
array_name = 'data'

html_to_c_array(html_file, output_file, array_name)

